package com.example.mqspring.rabiitmqbasicleverone.rabbitmq;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.MessageProperties;

public class Product {

    public void sendMessage(Channel channel, String myQueue) {

        String message = "这是我第一次发送rabbitmq";
        try {
//            第一次发送
            channel.basicPublish("",myQueue,null,message.getBytes("UTF-8"));
//          第二次发射 PERSISTENT_TEXT_PLAIN 这个属性意思是持久化``消息会存到硬盘
            channel.basicPublish("",myQueue, MessageProperties.PERSISTENT_TEXT_PLAIN,message.getBytes("UTF-8"));

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
